package com.xjtu.chapter08.thread.linkedblockingqueue;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;

/**
 * @author yjq
 * @version 1.0
 * @date 2021/9/1 10:48
 */
public class ProductConsumer {
    public static void main(String[] args) {
        //创建一个LinkdeBlockQueue
        BlockingQueue<Product>queue = new LinkedBlockingQueue<Product>();
        //创建Consumer对象和Producer对象
        Consumer consumer = new Consumer(queue);
        Producer producer = new Producer(queue);
        //创建5个Consumer线程和5个Producer线程
        for (int i = 0; i < 5; i++) {
            new Thread(producer,"Producer"+(i+1)).start();
            new Thread(consumer,"consumer"+(i+1)).start();
        }
    }
}
